<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Example: Create a Chart with a Time Axis</title>
    <link rel="stylesheet" href="http://yui.yahooapis.com/3.4.0pr3/build/cssgrids/grids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <script src="../../build/yui/yui-min.js"></script>
</head>
<body>

<div id="doc">
    <h1>Example: Create a Chart with a Time Axis</h1>

    

    <div class="yui3-g">
        <div id="main" class="yui3-u">
            <div class="content"><style scoped>
#mychart {
    margin:10px 10px 10px 10px;
    width:90%;
    max-width: 800px;
    height:400px;
}
</style>
<div class="intro">
<p>This example shows how to create a <code>Chart</code> with a Time Axis.</p>
</div>
<div class="example">
<div id="mychart"></div>
<script type="text/javascript">
(function() {
    YUI().use('charts', function (Y) 
    { 
        var myDataValues = [ 
            {date:"1/1/2010", miscellaneous:2000, expenses:3700, revenue:2200}, 
            {date:"2/1/2010", miscellaneous:50, expenses:9100, revenue:100}, 
            {date:"3/1/2010", miscellaneous:400, expenses:1100, revenue:1500}, 
            {date:"4/1/2010", miscellaneous:200, expenses:1900, revenue:2800}, 
            {date:"5/1/2010", miscellaneous:500, expenses:7000, revenue:2650},
            {date:"6/1/2010", miscellaneous:3000, expenses:4700, revenue:1200}, 
            {date:"7/1/2010", miscellaneous:6550, expenses:6500, revenue:1100}, 
            {date:"8/1/2010", miscellaneous:4005, expenses:2600, revenue:3500}, 
            {date:"9/1/2010", miscellaneous:1200, expenses:8900, revenue:3800}, 
            {date:"10/1/2010", miscellaneous:2000, expenses:1000, revenue:3650},
            {date:"11/1/2010", miscellaneous:2000, expenses:3700, revenue:2200}, 
            {date:"12/1/2010", miscellaneous:5000, expenses:3100, revenue:4100}
        ];
        
        var mychart = new Y.Chart({
				dataProvider:myDataValues, 
				render:"#mychart", 
				styles: {
					axes: { 
						date: { 
							label: {
								rotation: -45
							}
						}
					}
				}, 
				categoryKey:"date", 
				categoryType:"time"
			});
    });
})();
</script>

</div>
<h3>This example shows how to create a Chart with a Time Axis.</h3>


<p>When plotting data across a range of dates, it's sometimes preferred to use <code>TimeAxis</code> instead of a <code>CategoryAxis</code>. While a <code>CategoryAxis</code> plots ticks on an
axis for each data point on a graph, a <code>TimeAxis</code> plots ticks evenly across a time range. A <code>TimeAxis</code> can be applied to a Chart by setting its <code>categoryType</code>
 attribute to "time".</p>

<pre class="code prettyprint">var myDataValues = [ 
    {date:&quot;1&#x2F;1&#x2F;2010&quot;, miscellaneous:2000, expenses:3700, revenue:2200}, 
    {date:&quot;2&#x2F;1&#x2F;2010&quot;, miscellaneous:50, expenses:9100, revenue:100}, 
    {date:&quot;3&#x2F;1&#x2F;2010&quot;, miscellaneous:400, expenses:1100, revenue:1500}, 
    {date:&quot;4&#x2F;1&#x2F;2010&quot;, miscellaneous:200, expenses:1900, revenue:2800}, 
    {date:&quot;5&#x2F;1&#x2F;2010&quot;, miscellaneous:500, expenses:7000, revenue:2650},
    {date:&quot;6&#x2F;1&#x2F;2010&quot;, miscellaneous:3000, expenses:4700, revenue:1200}, 
    {date:&quot;7&#x2F;1&#x2F;2010&quot;, miscellaneous:6550, expenses:6500, revenue:1100}, 
    {date:&quot;8&#x2F;1&#x2F;2010&quot;, miscellaneous:4005, expenses:2600, revenue:3500}, 
    {date:&quot;9&#x2F;1&#x2F;2010&quot;, miscellaneous:1200, expenses:8900, revenue:3800}, 
    {date:&quot;10&#x2F;1&#x2F;2010&quot;, miscellaneous:2000, expenses:1000, revenue:3650},
    {date:&quot;11&#x2F;1&#x2F;2010&quot;, miscellaneous:2000, expenses:3700, revenue:2200}, 
    {date:&quot;12&#x2F;1&#x2F;2010&quot;, miscellaneous:5000, expenses:3100, revenue:4100}
];

var mychart = new Y.Chart({
			dataProvider:myDataValues, 
			render:&quot;#mychart&quot;, 
			styles: {
				axes: { 
					date: { 
						label: {
							rotation: -45
						}
					}
				}
			}, 
			categoryKey:&quot;date&quot;, 
			categoryType:&quot;time&quot;
		});</pre>

</div>
        </div>

        <div id="sidebar" class="yui3-u">
            

            
                <div class="sidebox">
                    <div class="hd">
                        <h2 class="no-toc">Examples</h2>
                    </div>

                    <div class="bd">
                        <ul class="examples">
                            
                                
                                    <li data-description="Shows how to use Charts to create a basic chart.">
                                        <a href="charts-simple.html">Basic Charts Implementation</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with multiple series.">
                                        <a href="charts-multiseries.html">Chart with Multiple Series</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a column chart with multiple series.">
                                        <a href="charts-column.html">Specify Chart Type</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a column chart with a stacked numeric axis.">
                                        <a href="charts-stackedcolumn.html">Create Stacked Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with a time axis.">
                                        <a href="charts-timeaxis.html">Create a Chart with a Time Axis</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to add gridlines to a chart.">
                                        <a href="charts-gridlines.html">Add Gridlines to a Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with planar based events.">
                                        <a href="charts-stackedarea.html">Create a Stacked Area Chart with Planar Based Events</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to use a chart&#x27;s styles attribute to customize a chart.">
                                        <a href="charts-globalstyles.html">Customize a Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to customize the default tooltip of a chart.">
                                        <a href="charts-customizedtooltip.html">Customize a Chart&#x27;s Tooltip</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to explicitly define the axes and series for a chart.">
                                        <a href="charts-objectstyles.html">Define a Chart&#x27;s Axes and Series</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to use charts to create a pie chart.">
                                        <a href="charts-pie.html">Pie Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to create a chart with multiple value axes.">
                                        <a href="charts-dualaxes.html">Dual Axes Chart</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to access a chart instance&#x27;s value axis after the chart has rendered.">
                                        <a href="charts-axisupdate.html">Update Chart Axis</a>
                                    </li>
                                
                            
                                
                                    <li data-description="Shows how to access a chart instance&#x27;s seriesCollection after the chart has rendered.">
                                        <a href="charts-seriesupdate.html">Update Chart Series</a>
                                    </li>
                                
                            
                        </ul>
                    </div>
                </div>
            

            
        </div>
    </div>
</div>

<script src="../assets/vendor/prettify/prettify-min.js"></script>
<script>prettyPrint();</script>

</body>
</html>
